/******************************************************************************
  Modulo colafunciones
*******************************************************************************/
#include "queue.h"

void QueueInit(Queue *q, char buff[], unsigned char s)
{
  q->buffer = buff;
  q->size = s;
  q->head = 0;
  q->tail = 0;
}
char QueueGetData(Queue  *q)
{
  char c = q->buffer[q->tail++];
  if (q->tail== QueueSize(q))
    q->tail = 0;
  return c;
}

void QueueAddData(Queue * q, char c)
{
  if (1){
    q->buffer[q->head++] = c;
    if (q->head == QueueSize(q))
      q->head = 0;
  }
}

unsigned char QueueIsEmpty(Queue *q)
{
  return (q->head==q->tail);
}


unsigned char QueueSize(Queue * q){
  return q->size;
}